package cn.crm.controller;

import cn.crm.pojo.SalPlan;
import cn.crm.service.SalChanceService;
import cn.crm.service.SalPlanService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/SalPlan")
public class SalPlanController {
    @Autowired
    private SalPlanService salPlanService;

    @PostMapping("/Page")
    public Page<SalPlan> getJoinList(Page page){
        return salPlanService.getSalPlanPageJoinSalChance(page);
    }
    @GetMapping("/{chcId}")
    List<SalPlan> getSalPlanListByChcId(@PathVariable("chcId") Integer chcId){
        return salPlanService.getSalPlanListByChcId(chcId);
    }
    @PostMapping
    public boolean add(@RequestBody SalPlan salPlan){
        return salPlanService.save(salPlan);
    }
    @PutMapping
    public boolean update(@RequestBody SalPlan salPlan){
        return salPlanService.updateById(salPlan);
    }
    @DeleteMapping("/{plaId}")
    public boolean deleteById(@PathVariable Integer plaId){
        return salPlanService.removeById(plaId);
    }
}
